<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>视频管理</title>
    <div th:replace="fragment/header::css"></div>
    <div th:replace="fragment/header::js"></div>
</head>
<div th:replace="fragment/script::contextPath"></div>
<body>
<div class="layui-layout layui-layout-admin site-demo-fixed" >
  <div th:replace="fragment/nav::nav"></div>
  <div class="container" style="width: auto">
    <nav class="navbar navbar-light ">
      <div class="container-fluid justify-content-center" >
        <form class="form-inline">
          <input name="keyWord"  class="form-control mr-sm-2" style="width: 600px" type="search" placeholder="按评论内容搜索" aria-label="Search">
          <button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
        </form>
      </div>
    </nav>
    <div >
      <table class="table  table-striped">
        <thead>
        <tr>
          <th scope="col" style="text-align: center" width="250px">视频名称</th>
          <th scope="col" style="text-align: center">用户名称</th>
          <th scope="col" style="text-align: center">评论内容</th>
          <th scope="col" style="text-align: center">评论类型</th>
          <th scope="col" style="text-align: center">评论时间</th>
          <th scope="col" style="text-align: center">状态</th>
          <th scope="col" style="text-align: center">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr style="text-align: center" th:each="comment:${commentList}">
          <td th:text="${comment.mediaName}"></td>
          <td th:text="${comment.userName}"></td>
          <td th:text="${comment.commentText}"></td>
          <td th:switch="${comment.commentType}">
            <span th:case="0">视频</span>
            <span th:case="1">电影</span>
          </td>
          <td th:text="${#dates.format(comment.commentTime,'yyyy-MM-dd HH:mm:ss')}"></td>
          <td th:switch="${comment.commentStatus}">
            <span th:case="0">审核中</span>
            <span th:case="1">正常</span>
            <span th:case="2">封禁</span>
          </td>
          <td>
            <button type="button" class="btn btn-outline-info" th:onclick="commentConfirm([[${comment.commentId}]])">通过</button>
            <button type="button" class="btn btn-outline-info" th:onclick="commentRefuse([[${comment.commentId}]])">拒绝</button>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
</body>
</html>
<script>
  function commentConfirm(commentId){
    $.post(contextPath+"/admin/adminReviewComment",
            {commentId:commentId,commentStatus:1},
            function () {
              alert("操作成功");
              window.location.reload()
            })
  }
  function commentRefuse(commentId){
    $.post(contextPath+"/admin/adminReviewComment",
            {commentId:commentId,commentStatus:2},
            function () {
              alert("操作成功");
              window.location.reload()
            })
  }
</script>